import { NextApiRequest, NextApiResponse } from 'next'
import { dataService } from '../../../services'

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  if (!Array.isArray(req.query.all) || req.query.all.length == 0) {
    return res.status(404)
  }
  let id = req.query.all.join('/')
  let src = await dataService.getCoverUrl(id)
  if (src) {
    return res.redirect(src)
  }
  return res.status(404)
}
